package com.nbsaas.boot.queue.config;

import com.nbsaas.boot.queue.scheduler.TaskScheduler;
import com.nbsaas.boot.queue.scheduler.impl.DefaultTaskScheduler;
import com.nbsaas.boot.queue.storage.TaskStorage;
import com.nbsaas.boot.queue.storage.impl.MemoryTaskStorage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QueueConfig {

    private int threadPoolSize = 4;

    @Bean
    public TaskStorage taskStorage() {
        return new MemoryTaskStorage();
    }

    @Bean
    public TaskScheduler taskScheduler(TaskStorage taskStorage) {
        TaskScheduler scheduler = new DefaultTaskScheduler(threadPoolSize, taskStorage);
        scheduler.start();
        return scheduler;
    }
} 